package mysql

import "gorm.io/gorm"

type Orders struct {
	gorm.Model
	UserId     int64   `gorm:"type:int;index;not null;comment:'用户ID'"`
	OrderSn    string  `gorm:"type:char(36);unique;not null;comment:'订单号'"`
	Amount     float64 `gorm:"type:decimal(10,2);not null;comment:'订单金额'"`
	Payment    int     `gorm:"type:tinyint(1);not null;default:1;comment:支付类型:1支付宝2微信"`
	Status     int     `gorm:"type:tinyint(1);default:1;not null;comment:'订单状态:1待支付2已支付3已取消4已完成'"`
	GodsId     uint    `gorm:"type:int;index;not null;comment:'商品ID'"`
	GoodsTitle string  `gorm:"type:varchar(50);not null;comment:'商品名称'"`
	GoodsNum   int     `gorm:"type:int;not null;comment:'商品数量'"`
	GoodsPrice float64 `gorm:"type:decimal(10,2)not null;comment:'商品价格'"`
}

func (o *Orders) Create() error {
	return DB.Debug().Create(&o).Error
}
